﻿@{
    ViewData["Title"] = "文章信息";
    Layout = "~/Views/Shared/_Index.cshtml";
}
<div class="container-div white-bg">
    <div class="row">
        <div class="col-sm-12">
            <div class="tabs-container">
                <form class="form form-horizontal" id="contentForm">
                    <input type="hidden" name="id" id="id" value="@(ViewBag.Id)">
                    <input type="hidden" name="channel_id" id="channel_id" />
                    <div class="nav-tabs-custom">
                        <ul class="nav nav-tabs">
                            <li class="active">
                                <a data-toggle="tab" href="#tab-content" aria-expanded="true">资讯内容</a>
                            </li>
                            <li class="">
                                <a data-toggle="tab" href="#tab-set" aria-expanded="false">文章设置</a>
                            </li>
                        </ul>
                        <div class="tab-content ">
                            <div id="tab-content" class="tab-pane active">
                                <div class="panel-body">
                                    <div class="form-group">
                                        <label class="col-sm-2 control-label required">编号：</label>
                                        <div class="col-sm-7">
                                            <input type="text" name="stock_no" id="stock_no" value="" class="form-control" data-rule="required;">
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-sm-2 control-label required">名称：</label>
                                        <div class="col-sm-7">
                                            <input type="text" name="stock_name" id="stock_name" value="" class="form-control" data-rule="required;">
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">内容摘要：</label>
                                        <div class="col-sm-8">
                                            <textarea cols="80" rows="4" id="stock_tags" name="stock_tags"></textarea>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <div class="col-sm-11" style="margin-left: 50px;">
                                            <textarea id="stock_info" name="stock_info" style="height:600px;"></textarea>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div id="tab-set" class="tab-pane">
                                <div class="panel-body">
                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">文章属性：</label>
                                        <div class="col-sm-6">
                                            <div class="checkbox checkbox-success checkbox-inline">
                                                <input type="checkbox" id="is_top" name="is_top" value="1">
                                                <label for="is_top">置顶</label>
                                            </div>
                                            <div class="checkbox checkbox-success checkbox-inline">
                                                <input type="checkbox" id="is_recommend" name="is_recommend" value="1">
                                                <label for="is_recommend">推荐</label>
                                            </div>
                                        </div>

                                    </div>
                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">作者：</label>
                                        <div class="col-sm-6">
                                            <input type="text" name="author" id="author" value="" class="form-control">
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">来源：</label>
                                        <div class="col-sm-6">
                                            <input type="text" name="source" id="source" value="" class="form-control">
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">浏览量：</label>
                                        <div class="col-sm-6">
                                            <input type="number" name="hit_count" id="hit_count" value="1" class="form-control">
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">审核状态：</label>
                                        <div class="col-sm-4">
                                            <div class="radio radio-success radio-inline">
                                                <input type="radio" id="content_status" value="2" name="content_status">
                                                <label for="status">草稿</label>
                                            </div>
                                            <div class="radio radio-success radio-inline">
                                                <input type="radio" id="content_status2" value="0" name="content_status">
                                                <label for="status2">待审核</label>
                                            </div>
                                            <div class="radio radio-success radio-inline">
                                                <input type="radio" id="content_status3" value="1" name="content_status" checked="">
                                                <label for="status3">审核通过</label>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">外部链接：</label>
                                        <div class="col-sm-6">
                                            <input type="text" name="content_href" id="content_href" value="" class="form-control">
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">添加时间：</label>
                                        <div class="col-sm-4">
                                            <input type="text" name="publish_time" id="publish_time" value="@(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"))" onclick="WdatePicker({isShowClear:false,dateFmt:'yyyy-MM-dd HH:mm:ss'})" class="form-control" style="width:200px;" readonly="readonly">
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="hr-line-dashed"></div>
                    <div class="footerbar">
                        <div class="col-sm-12 col-sm-offset-3">
                            <button class="btn btn-primary" type="submit">
                                <i class="fa fa-check"></i>
                                发布文章
                            </button>
                            <button class="btn btn-danger" type="button" onclick="cancel()">
                                <i class="fa fa-reply-all"></i>关闭
                            </button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
@section scripts{
    <script src="~/ui/plugins/My97DatePicker/WdatePicker.js"></script>
    <script src="~/ui/plugins/ueditor/ueditor.config.js"></script>
    <script src="~/ui/plugins/ueditor/ueditor.all.js"></script>
    <script>
        let editor;
        $(function () {
            let id = jutils.getQueryParam('id');

            $('#contentForm').validator({
                stopOnError: false,
                timely: 2,
                theme: "yellow_right",
                valid: function (form) {
                    // 表单验证通过，提交表单
                    jutils.ajaxPost('/stock/stockRemark/Save', $(form).serialize(),
                        function (res) {
                            jutils.postMessage('cms_content_form', "save content");
                            cancel();
                        });
                }
            });
            //初始化文本编辑器
            editor = UE.getEditor('stock_info');
            loadData();
        });

        function loadData() {
            var id = jutils.getQueryParam("id");
            jutils.ajaxGet('/stock/stockRemark/getmodel', { id: id }, function (res) {
                if (id != '0') {
                    var model = res.data.model

                    $('#contentForm').initFormData(model);
                   
                    editor.ready(function () {
                        editor.setContent(model.stock_info);
                    });
                }
            });

        }


      
        function cancel() {

            jutils.closeTab();
        }

    </script>
}






